include Enum

class Deck < Serializable

  attr_reader :source

  def hand_out
    @source = deckOfCards.shuffle
    invalidate
  end

  def trump
    return @source.last
  end

  def count
    return @source.length
  end

  def empty?
    return @source.empty?
  end

  def invalidate
    @source.each{ |card| card.isTrump = (card.suit == trump.suit) }
  end

  def getCards(count)
    result = []

    while (count > 0 && !empty?)
      result.push( @source.shift )
      count -= 1
    end

    return result
  end


  private
  def deckOfCards
    result = []
    9.times{ |i| 4.times { |j| result.push( Card.new(i, j)) } }
    return result
  end

end